<!DOCTYPE html>
<html>
<head>
<Title>TBA Activity Registration || User Page</Title>
	<!-- a css3 formalasokhoz szukseges dolgok -->
	<link href="Design.css" rel="stylesheet" type="text/css">
	<!-- javascript a fancyboxhoz szukseges-->
	<script type="text/javascript" src="libraries/jquery-1.9.0.min.js"></script>
	<script type="text/javascript" src="libraries/jquery.fancybox.js?v=2.1.4"></script>
	<link rel="stylesheet" type="text/css" href="libraries/jquery.fancybox.css?v=2.1.4" media="screen" />
	<!-- fancybox egy javascript alapu aplikacio ami egy boxot jelenit meg-->
	<!-- ezzel a boxxal oldjuk meg hogy hozaadjon vagy toroljon tevekenysegeket a felhasznalo-->
	<script type="text/javascript">
		function nextmonth(year,month,day){	<!--honap lepesekhez felelos fuggveny amellyel elore mehet honaponkent-->
			if (month == 12){year++;month = 1;}
			else{month++;}
			window.location.href = 'calendar.php?year=' + year + '&month=' + month + '&day=' + day;
		}
		function prevmonth(year,month,day){<!--honap lepesekhez felelos fuggveny amellyel vissza mehet honaponkent-->
			if (month == 1){year--;month = 12;}
			else{month--;}
			window.location.href = 'calendar.php?year=' + year + '&month=' + month + '&day=' + day;
		}
		$(document).ready(function() {<!--a felugro ablakocskara felelos fuggveny-->
			$('.fancybox').fancybox({
				autoSize: false,
				width: 380,
				height: 350
			});
		});
	</script>
</head>
<Title>TBA Activity Registration || User Page</Title>
<body>
<?php
	//bejelentkezes utan megkapjuk az aktualis ev/ho/napot
	$year=wordwrap($_GET['year']);
	$month=wordwrap($_GET['month']);
	$day=wordwrap($_GET['day']);
	//naptarhoz kiszamoljuk az adott honap kezdeti es vegso napjat
	$time = strtotime("$year-$month-$day");
	$sday=date('N', strtotime('first day of this month', $time));
	$nrday=date('j', strtotime('last day of this month', $time));
	//honap es ev kiirasa az aktualis datumnak
	$actdate=date("F Y",$time);
	session_start();
	if (isset($_SESSION['username']) && !empty($_SESSION['username']))
		//felhasznalonevet aki bejelentkezett lementjuk sessionbe
		$username=$_SESSION['username'];
	else
		header("location:index.html?error=session");
?>
<div id="title">User page
<!-- Logout gomb amivel kitoroljuk a sessionbol az eddigi adatokat-->
<form action="BLL.php"><input id="button" name="logout" type="submit" value="Logout"/></form></div><br>
	<div id="field">
		<table>
			<caption>
				<div id="subtitle">
				<!-- Honapot 1-el visszabb leptetni -->	
						<button id="button" onclick="prevmonth(<?php echo "$year,$month,$day";?>)"> Prev month </button>					
							<?php $a=$actdate; echo "$a"; ?>
						<!-- Honapot 1-el elorebb leptetni -->		
						<button id="button" onclick="nextmonth(<?php echo "$year,$month,$day";?>)"> Next month </button>
				</div>
			</caption>
			<!-- napok neveit a tablazatba kiirva-->
			<thead>
				<th>Monday</th>
				<th>Tuesday</th>
				<th>Wednesday</th>
				<th>Thursday</th>
				<th>Friday</th>
				<th>Saturday</th>
				<th><div id="weekend">Sunday</div></th>
			</thead>
			<form action="BLL.php" method="get">
				<tbody>
					<tr>	
					<!-- Vegigmegyunk a honap elso napjaig hetofotol kezdve ures mezokat hozva letre-->	
						<?php
							for ($i=1;$i<$sday;$i++){
						?>
						<td></td>
						<?php
							}
							$db = 1;
							include "classes.php";
							$tmpclass = new activityhours;
							$field = $sday;
							$a=1;
							for ($db=1; $db<=$nrday; $db++){
								if ((($field-1) % 7) == 0){
									$a = 1;
						?>
						<!-- majd ezutan elsejetol kezdve vegigmegyunk a honapon -->	
					</tr><tr>
						<?php
								}
								//egy hozzaadas gomb es egy delete gomb
						?>
						<td>
								<?php if ($field % 7 == 0){
								?>
								<div id="weekend">
								<?php 
									  }
									  echo "$db.";
									  if ($field % 7 == 0){
								?>
								</div><!--minden naphoz kilistazzuk a bejelentkezo felhasznalo aktivitasait egy aktivias hozzaado es torlo gommbbal felettuk-->	
								<?php }
								?>
						<a class="fancybox fancybox.iframe" href="addactivity.php?<?php echo "year=$year&month=$month&day=$db";?>"><img id="icon" src="add.png"></a>
						<a class="fancybox fancybox.iframe" href="deleteactivity.php?<?php echo "year=$year&month=$month&day=$db";?>"><img id="icon" src="delete.jpg"></a>
						<?php
								//ezutan pedig lista az aktivitasokkal az adott napon
								$list="";
								$tmpclass->set_username($username);
								$tmpclass->getactivityhourlistdbhtml("$year-$month-$db 00:00:00","$year-$month-$db 23:59:59",$list);
								echo "$list";
								$field++;
								$a++;
						?>
						</td>
						<?php
							}
							for ($i=$a; $i<8; $i++){
						?>
						<!--majd kitoltjuk ures mezokkel az utolso sort-->
						<td></td>
						<?php
							} 
						?>
					</tr>
				</tbody>
			</form>
		</table>
	</div>
</body>
</html>